<!doctype html public "-//w3c//dtd html 4.01//en">
<html>
		<?php include("php/head.php"); ?>
	<body>
		<?php include("php/header.php"); ?>
		
		<!-- CONTENT -->
		<div class="meey_content">
			<h1> Database Connection </h1>
			<p>
			Connect to the Database
			</p>
			
			<?php
			
				$link = mysql_connect('localhost', 'meey', 'algorithm77');
				if (!$link) {
					die('Could not connect: ' . mysql_error());
				}
				echo 'Connected successfully';
				
				@mysql_select_db('world') or die( 'Unable to select database'  . mysql_error());
				
				$num=0;
				
				//$query="Select * from city";
				$query='CALL search_world()';
				$result=mysql_query($query);
				
				$num=mysql_numrows($result);
				
				echo "<p>$num</p>";
				echo "<table>";
				
				$i=0;
				while ($i < $num) {
					$field0=mysql_result($result,$i,"Name");
					$field1=mysql_result($result,$i,"CuntryCode");
					$field2=mysql_result($result,$i,"District");
					$field3=mysql_result($result,$i,"Population");
					echo "
					<tr>
					<td>$field0</td>
					<td>$field1</td>
					<td>$field2</td>
					<td>$field3</td>
					</tr>
					";

					$i++;
				}
				
				echo "</table>";
				
				mysql_close($link);
			?>


			<!-- END Carousel -->
			<div class="clearboth"></div>

		</div>
		
		<?php include("php/footer.php"); ?>
	</body>
</html>